#include <stdio.h>
#include <graphics.h>
#include "vectors.h"
#include "gravity.h"

int main()
{
 float k=0.1;
    initwindow(1000,1000);
    vector r(800.0,-1350.0),v(0.0,2.0),a,dr(1000.0,0.0);
    moveto((int)(r.x*k+500.0),(int)(-r.y*k+500));
    circle(500,500,10);
    circle(600,500,10);
    float t2,t=0.005;
    int i,c=0;
    t2=t*t/2;
    while(1)
    {
        r=r+(t*v+t2*a);
        v=v+t*a;
        a=gravity(r,v)+gravity(r,v,dr);
        c=c+1;
        if(c==100)
        {
            c=0;
            t=1/(50*v.length());
            t2=t*t/2;
        }
        lineto((int)(r.x*k+500.0),(int)(-r.y*k+500));
        moveto((int)(r.x*k+500.0),(int)(-r.y*k+500));
    }
    printf("stop");
    getch();
    closegraph();
    return 0;    
}
